package cn.orangelite.ai.controller;

import cn.orangelite.ai.domain.qianfan.ErnieContentDTO;
import cn.orangelite.ai.domain.qianfan.StableDiffusionXLDTO;
import cn.orangelite.ai.domain.qianfan.StableDiffusionXLResult;
import cn.orangelite.ai.service.IAiInfoService;
import cn.orangelite.common.core.web.controller.BaseController;
import cn.orangelite.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/ai")
@RestController
public class AiInfoController extends BaseController {

    @Autowired
    private IAiInfoService iAiInfoService;


    @PostMapping("/sendContent")
    public AjaxResult sendContent(@RequestBody ErnieContentDTO ernieContentDTO){
        String token = iAiInfoService.getQianfanToken();
        return success(iAiInfoService.sendContent(ernieContentDTO.getContent(),token));
    }

    @PostMapping("/createImage")
    public AjaxResult createImage(@RequestBody StableDiffusionXLDTO stableDiffusionXLDTO){
        String token = iAiInfoService.getQianfanToken();
        return success(iAiInfoService.createImage(stableDiffusionXLDTO.getPrompt(),token));
    }
}
